<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  function arr(nums) {
    const ans = [];
    const n = nums.length;
    for (let mask = 0; mask < (1 << n); ++mask) {
      const t = [];
      for (let i = 0; i < n; ++i) {
        if (mask & (1 << i)) {
          t.push(nums[i]);
        }
      }
      ans.push(t);
    }
    return ans;
  };
  console.log(arr(nums = [1, 2, 3]));
</script>

</html>